<!-- D:\project\app\ydz-app-uniapp\static\images\mine -->
<template>
	<view class="pagebody" :style="{ 'min-height': maxHeight }">
		<view class="topbox">
			<view class=" justify-between align-center">
				<view class=" flex-row align-center">
					<image @click="backpage" src="@/static/images/login/leftjt.png" alt=""
						style="width: 48rpx;height: 48rpx;"></image>
				</view>
				<view class="color303b39 fz40 fwbold">
					{{title}}
				</view>
				<view @click="submit" class=" fz36 color303b39">
					完成
				</view>
			</view>
		</view>
		<view class="" style="margin-top: 110rpx;padding: 0 24rpx;">
			<textarea v-show="typeid!=4" contenteditable="true" v-model="content" class="textareabox color303b39 fz36"
				style="padding: 24rpx;line-height: 64rpx;border: 1rpx solid #B8C3C1; width: auto;" name="" id=""
				cols="30" maxlength="4000" :placeholder="'您正在输入'+title"></textarea>
			<uni-easyinput v-show="typeid==4" type="text" v-model="content" :placeholderStyle="placeholderStyle"
				:placeholder="'您正在输入'+title"></uni-easyinput>
			<view v-show="content.length>0" class="mt16 flex-row align-center justify-end" style="color: #7E8987;">
				您已输入 <span style="color:#FC4112 ;">{{content.length}}</span>个字符
			</view>
		</view>
	</view>
</template>

<script>
	import {
		editdocument
	} from '@/api/api.js'
	export default {

		onLoad(option) {
			// 获得屏幕最大高度
			let systemInfo = uni.getSystemInfoSync();
			this.maxHeight = systemInfo.windowHeight + "px";
			console.log(option)
			this.typeid = option.type
			if (option.type == 1) {
				this.title = '修改正在服用药品'
			} else if (option.type == 2) {
				this.title = '正在使用的疗法'
			} else if (option.type == 3) {
				this.title = '目前治疗效果'
			} else if (option.type == 4) {
				this.title = '昵称'
			}
		},
		data() {
			return {
				placeholderStyle: "color:#7E8987;font-size:32rpx",
				maxHeight: '',
				title: '',
				typeid: 0,
				content: ''

			}
		},
		created() {},
		mounted() {},
		onShow() {

		},

		methods: {
			backpage() {
				uni.navigateBack({
					delta: 1
				});
			},
			submit() {
				let data = {}
				if (this.typeid == 1) {
					data = {
						'drugName': this.content
					}
				} else if (this.typeid == 2) {
					data = {
						'therapy': this.content
					}
				} else if (this.typeid == 3) {
					data = {
						'treatmentEffect': this.content
					}
				} else if (this.typeid == 4) {
					data = {
						'userName': this.content
					}
				}
				
				editdocument(data).then(res => {
					uni.navigateBack({
						delta: 1
					});
				})


			}
		},

	}
</script>

<style lang="scss" scoped>
	.pagebody {
		padding-bottom: 136rpx;
		background: #fff;

		.topbox {
			height: 88rpx;
			background: #fff;
			padding: 20rpx 24rpx;
		}



	}
</style>